home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr30
/
clsh.zip
/
CLSH.ASM
next >
Wrap
Assembly Source File
|
1993-05-04
|
6KB
|
237 lines
; Clear Screen and Hold
; By Matthew J. W. Ratcliff
; Ratware Softworks
; PUBLICWARE
; Distribute this code FREEly
;
; Clear the screen and hold until a key is pressed.
; The text display is switched from screen 0 to screen 1.
; A '#' character is printed at random positions on the
; display once every two seconds - just to let you know
; the computer is on. (A completely blank screen might fake
; you out and cause you to power cycle the computer.)
; When any key is pressed, the display is switched back to
; screen 0 - with the information originally there intact.
; This can be called from the dos command line or shell
; from any other program capable of executing DOS commands.
; Use this utility to clear the screen and prevent
; phosphor burn. Why WASTE memory on another TSR when
; you don't have to? Use CLSH! A petite 1280 byte .EXE file
; written with MASM 4.0
; I originally wrote this with Microsoft C 5.1. Although the
; C source code was under 1300 bytes, the executable was over 18k!
; With the help of The NEW Peter Norton "Programmer's Guide to the
; IBM PC & PS/2" I was able to rewrite CLSH as a stand alone
; assembly language program. The source file is about 5K, and the
; executable only 1280 bytes. There are times when it PAYS to use
; assembly language! Mat*Rat PPN: 76703,1077
PAGE ,132 ; (CTRL-OH) IBM PC PRINTER CONDENSED MODE
TITLE SKELEXE2 - SAMPLE.EXE STYLE WITH DOS 2.0+ EXIT INTERFACE
DSEG SEGMENT PARA PUBLIC 'DATA'
;insert data here
TIME18 DW 0
DELAY DB 0, 0
BLIPX DB 0
BLIPY DB 0
SPACE DB ' $'
PERIOD DB '#$'
MYNAME DB 'Clear Screen and Hold, by Mat*Rat$'
DSEG ENDS
CSEG SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CSEG,SS:STACK ;ALREADY SET BY DOS LOADER
;insert constants here
ONESECOND EQU 18
NORMSCR EQU 0
CLRSCR EQU 1
ENTPT PROC FAR ;ENTRY POINT FROM DOS
MOV AX,DSEG ;SET UP ADDRESSABILITY TO
MOV DS,AX ; THE DATA SEGMENT
ASSUME DS:DSEG ;TELL ASSEMBLER WHAT I JUST DID
;insert code here
; Select Text Screen #1
CALL ENACLR
; Get current time
MOV AH,00H
INT 1AH
MOV TIME18,DX
; Iniz RANDOM X & Y
CALL GETNEWXY
; Now clear the display
MOV AH,06H ; Scroll function
MOV AL,24 ; Scroll 25 lines
MOV BH,0 ; fill attribute
MOV CX,0000H ; Upper row:left column
MOV DX,256*24+79 ; Lower row:right column
INT 10H ; Video interrupt service
; Now wait for a keypress to exit
KEYWAIT:
MOV AH,01H ; Keyboard status
INT 16H ; Keyboard interrupt service
JNE KEYEXIT ; Not zero, wait
MOV AH,00
INT 1AH
MOV CX,DX
SUB DX,TIME18
CMP DX,ONESECOND
JL KEYWAIT
MOV TIME18,CX
DOBLIP:
INC DELAY ; Blip on or off?
MOV AL,DELAY
AND AL,01H
CMP AL,0
JE BLIPON
BLIPOFF:
CALL EBLIP
CALL GETNEWXY
JMP SHORT KEYWAIT
BLIPON:
CALL SBLIP
JMP SHORT KEYWAIT
; Now fetch the keypress and exit
KEYEXIT:
MOV AH,00H ; Keyboard read
INT 16H ; Keyboard interrupt service
; Now switch back to screen 0
CALL ENANORM
MOV DX,OFFSET MYNAME
CALL WRITE
RET_CD EQU 0 ;ERRORLEVEL RETURN CODE VALUE
RET_FN EQU 4CH ;"RETURN TO DOS" FUNCTION CALL
MOV AX,RET_FN*256 + RET_CD ;RETURN TO DOS FUNCTION CALL, AND
;VALUE TO BE PASSED TO ERRORLEVEL
INT 21H ;RETURN TO DOS
; (VERSION 2.00 OR LATER)
ENTPT ENDP
; EBLIP - Print a space character at the current BLIPX, BLIPY
EBLIP PROC NEAR
CALL SETPOS
MOV DX,OFFSET SPACE
CALL WRITE
RET
EBLIP ENDP
; SBLIP - Print a '.' character at the new BLIPX, BLIPY
SBLIP PROC NEAR
CALL SETPOS
MOV DX, OFFSET PERIOD
CALL WRITE
RET
SBLIP ENDP
; SETXY - Take AX and put valid X and Y values in BLIPX, BLIPY
SETXY PROC NEAR
AND AH,1FH ; Generate random Y
CMP AH,23 ; Greater than 23?
JL SETXY1
MOV AH,22
SETXY1:
MOV BLIPY,AH
AND AL,7FH ; Generate random X
CMP AL,80 ; Greater than 79?
JL SETXY2
MOV AL,79
SETXY2:
MOV BLIPX,AL
RET
SETXY ENDP
; SETPOS - Take BLIPX, BLIPY and set cursor position
SETPOS PROC NEAR
MOV BH,CLRSCR ; Page number 1
MOV AH,02H ; Set cursor pos. function
MOV DH,BLIPY
MOV DL,BLIPX
INT 10H ; Video interrupt service
RET
SETPOS ENDP
; GETNEWXY - Read time and use 18.2HZ count value as random X,Y
GETNEWXY PROC NEAR
MOV AH,00 ; Read clock counter
INT 1AH ; Read clock interrupt service
MOV AX,DX
OR DL,DH
XOR AH,DL
CALL SETXY
RET
GETNEWXY ENDP
; WRITE - Send the character in AL to the video display
WRITE PROC NEAR
MOV AH,09H
INT 21H
RET
WRITE ENDP
; ENACLR - Enable the clear and hold screen
ENACLR PROC NEAR
MOV AH,05H
MOV AL,CLRSCR
INT 10H
RET
ENACLR ENDP
; ENANORM - Enable the normal screen
ENANORM PROC NEAR
MOV AH,05H
MOV AL,NORMSCR
INT 10H
RET
ENANORM ENDP
CSEG ENDS
STACK SEGMENT PARA STACK 'STACK'
DB 64 DUP("STACK ") ;256 WORD STACK AREA
STACK ENDS
END ENTPT